﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;
using UnityEngine.UI;

public class Slice : MonoBehaviour {

	public enum Type { Slice1, Slice2, Slice3 };
    public Type type;
    public int angle;
    public GameObject addScorePrefab;
    public Transform[] addScoreTrs;

    public void ApplyAngle(int angle)
    {
        this.angle = angle;

        int i = 0;
        foreach(Transform mask in transform)
        {
            mask.localRotation = Quaternion.Euler(0, 0, (angle + i) * 60);
            mask.GetChild(0).localRotation = Quaternion.Euler(0, 0, - (angle + i) * 60);
            i++;
        }
    }

    public void AddScoreEffect()
    {
        foreach(Transform tr in addScoreTrs)
        {
            var effect = Instantiate(addScorePrefab);
            effect.transform.SetParent(transform);
            effect.transform.localScale = Vector3.zero;
            effect.transform.position = tr.position;
            Destroy(effect, 2);

            effect.transform.DOMove(effect.transform.position + Vector3.up * 0.8f, 0.3f);
        }
    }

    public void SetSprite(Sprite sprite)
    {
        foreach (var image in GetComponentsInChildren<Image>())
        {
            image.sprite = sprite;
        }
    }

    public void TEXT1()
    {
        int textNum = 1;
        if (textNum == 1)
        {
            textNum = 2;
        }
    }
    public void TEXT2()
    {
        int textNum = 1;
        if (textNum == 1)
        {
            textNum = 2;
        }
    }
    public void TEXT3()
    {
        int textNum = 1;
        if (textNum == 1)
        {
            textNum = 2;
        }
    }

    public void TEXT4()
    {
        int textNum = 1;
        if (textNum == 1)
        {
            textNum = 2;
        }
    }

    public void TEXT5()
    {
        int textNum = 1;
        if (textNum == 1)
        {
            textNum = 2;
        }
    }

    public void TEXT6()
    {
        int textNum = 1;
        if (textNum == 1)
        {
            textNum = 2;
        }
    }

    public void TEXT8()
    {
        int textNum = 1;
        if (textNum == 1)
        {
            textNum = 2;
        }
    }

    public void TEXT9()
    {
        int textNum = 1;
        if (textNum == 1)
        {
            textNum = 2;
        }
    }

    public void TEXT10()
    {
        int textNum = 1;
        if (textNum == 1)
        {
            textNum = 2;
        }
    }

    public void TEXT11()
    {
        int textNum = 1;
        if (textNum == 1)
        {
            textNum = 2;
        }
    }

    public void TEXT12()
    {
        int textNum = 1;
        if (textNum == 1)
        {
            textNum = 2;
        }
    }

    public void TEXT13()
    {
        int textNum = 1;
        if (textNum == 1)
        {
            textNum = 2;
        }
    }

    public void TEXT14()
    {
        int textNum = 1;
        if (textNum == 1)
        {
            textNum = 2;
        }
    }

    public void TEXT15()
    {
        int textNum = 1;
        if (textNum == 1)
        {
            textNum = 2;
        }
    }

    public void TEXT16()
    {
        int textNum = 1;
        if (textNum == 1)
        {
            textNum = 2;
        }
    }

    public void TEXT17()
    {
        int textNum = 1;
        if (textNum == 1)
        {
            textNum = 2;
        }
    }
}
